﻿using CrazyCancer.Framework.ShortUrl;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using CrazyCancer.Framework.Communication.Interfaces;
using CrazyCancer.Framework.Communication;
namespace CrazyCancerFramework.ShortUrl.Tests.VisualStudio
{
    
    
    /// <summary>
    ///This is a test class for TinyUrlTest and is intended
    ///to contain all TinyUrlTest Unit Tests
    ///</summary>
    [TestClass()]
    public class when_shortening_an_url_using_tinyurl
    {

        /// <summary>
        ///A test for ShortenUrl
        ///</summary>
        [TestMethod()]
        public void should_return_4qz_for_cnn()
        {
            TinyUrl target = new TinyUrl(); // TODO: Initialize to an appropriate value
            string longUrl = "http://www.cnn.com";
            string apiUrl = "http://tinyurl.com/api-create.php?url=";
            string expected = "http://tinyurl.com/4qz";
            ICommunicator communicator = new HttpCommunicator();

            string actual;
            actual = target.ShortenUrl(longUrl, apiUrl, communicator);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for ShortenUrl
        ///</summary>
        [TestMethod()]
        public void should_return_4qz_for_cnn_with_user_name_and_password()
        {
            TinyUrl target = new TinyUrl();
            string longUrl = "http://www.cnn.com";
            string apiUrl = "http://tinyurl.com/api-create.php?url=";
            string userName = "test";                                   // TODO: Initialize to an appropriate value
            string password = "test";                                   // TODO: Initialize to an appropriate value

            string expected = "http://tinyurl.com/4qz";
            ICommunicator communicator = new HttpCommunicator();

            string actual;
            actual = target.ShortenUrl(longUrl, apiUrl, communicator, userName, password);
            Assert.AreEqual(expected, actual);
        }
    }
}
